package com.qcby.llmtchstd.controller;

import com.qcby.llmtchstd.entity.Student;
import com.qcby.llmtchstd.service.ClassService;
import com.qcby.llmtchstd.common.ResponseResult;
import com.qcby.llmtchstd.entity.Class;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping(value = "/class")
@Api(tags = "班级管理")
public class ClassController {
    @Autowired
    private ClassService classService;

    @RequestMapping(value = "/count", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取数量")
    public ResponseResult count() {
        return classService.count();
    }

    @RequestMapping(value = "/page", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("显示班级信息")
    public ResponseResult page(@RequestBody List<Integer> params) {
        Integer page = params.get(0);
        Integer pageSize = params.get(1);
        return classService.page(page, pageSize);
    }

    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("添加班级信息")
    public ResponseResult add(@RequestBody Class clazz) {
        return classService.add(clazz);
    }

    @RequestMapping(value = "/search", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("查询班级信息")
    public ResponseResult search(@RequestBody Class clazz) {
        return classService.search(clazz);
    }

    @RequestMapping(value = "/update", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("修改班级信息")
    public ResponseResult update(@RequestBody Class clazz) {
        return classService.update(clazz);
    }

    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("删除班级信息")
    public ResponseResult delete(@RequestBody Integer id) {
        return classService.delete(id);
    }

    @RequestMapping(value = "/edit", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("查询要修改的班级信息")
    public ResponseResult edit(@RequestBody Integer id) {
        return classService.edit(id);
    }

    @RequestMapping(value = "/serCount",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("获取搜索后的数量" )
    public ResponseResult serCount(@RequestBody Class clazz){
        return classService.serCount(clazz);
    }

    @RequestMapping(value = "/pageById", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("显示班级信息")
    public ResponseResult pageById(@RequestBody Class clazz) {

        return classService.pageById(clazz);
    }

}

